package com.ticket.common.utils.wechat.sdk;

import java.lang.reflect.Field;
import java.util.SortedMap;
import java.util.TreeMap;

public class AbstractRequestProtocol {
	
	public SortedMap<Object,Object> toMap() {
		SortedMap<Object,Object> map = new TreeMap<Object,Object>();
		Field[] fields = this.getClass().getDeclaredFields();
		for (Field field : fields) {
			Object obj;
			try {
			    field.setAccessible( true );
				obj = field.get(this);
				if (obj != null) {
					map.put(field.getName(), obj);
				}
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return map;
	}
	
}
